package com.yq.homework.day23;

import com.sun.xml.internal.ws.api.pipe.NextAction;
import jdk.management.resource.internal.inst.SocketOutputStreamRMHooks;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

/**
 * @author 3307235355@qq.com
 * @since 2022/06/23 20:22
 * 分别键盘输入文件名 和 文件内容，
 * 并按照文件名保存相应的文件内容
 */
public class Demo05 {
    public static void main(String[] args)  {
        Scanner scanner = new Scanner(System.in);
        System.out.println("输入文件名:");
        String s = scanner.nextLine();
        System.out.println("请输入文件的内容：");
        String s1 = scanner.nextLine();
        try (FileOutputStream file = new FileOutputStream(s)){
            file.write(s1.getBytes());
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
